package com.daniu101.productbargan.utils;

import org.springframework.util.DigestUtils;

import java.util.Random;

public class StringUtils {

    // 生成任意长度的数字字符串
    public static String getRandom(int length){

        StringBuilder str=new StringBuilder();
        Random random = new Random();
        //随机生成数字，并添加到字符串
        for(int i=0;i<length;i++){
            str.append(random.nextInt(10));
        }
        return str.toString();
    }

    //MD5加密
    public static String  getMd5(String string) {
        return DigestUtils.md5DigestAsHex(string.getBytes());
    }


}
